package com.whp.circle;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import javax.annotation.PostConstruct;

/**
 * @author wanghp
 * @version 1.0
 * @date 2020/6/27 18:07
 */

public class A implements BeanNameAware, BeanClassLoaderAware, BeanFactoryAware, InitializingBean, ApplicationContextAware {

	private B b;

	public A() {
	}

	public A(B b) {
		this.b = b;
	}

	public B getB() {
		return b;
	}

	public void setB(B b) {
		this.b = b;
	}

	//	private B b;
//
//	public void print() {
//		System.out.println("A");
//		b.print();
//	}
//
//
//	public B getB() {
//		return b;
//	}
//
//	public void setB(B b) {
//		this.b = b;
//	}

	@Override
	public void setBeanName(String name) {
		System.out.println("BeanNameAware");
	}

	@Override
	public void setBeanClassLoader(ClassLoader classLoader) {
		System.out.println("BeanClassLoaderAware");
	}


	@Override
	public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
		System.out.println("BeanFactoryAware");
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		System.out.println("InitializingBean");
	}

	@PostConstruct
	public void pointCut() {
		System.out.println("pointCut");
	}


	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		System.out.println("A - 后置处理器调用ApplicationContextAware");
	}
}
